//
//  DateSelect.swift
//  GOFM
//
//  Created by siri on 2024/11/8.
//  Copyright © 2024 Glad. All rights reserved.
//  月日历弹窗

import SwiftUI

struct DateSelect: View {
    @State var selectYear:String = String(Date.getCurrentYearNum()) // 选择的年份
    @State  var selectMonth:String = String(Date.getCurrentMonthNum()) // 选择的月份
    @State private var currentDate = Date() // 当前日期
  
    var body: some View {
        VStack {
            ModalPage(content:{
            
                VStack(spacing: 0) {
                    HStack {
                        // 选择上个月日期
                        Button(action: {
                            currentDate = currentDate.previousMonth()
                            selectYear = Date.getYearByDate(date: self.currentDate)
                            selectMonth = Date.getMonthByDate(date: self.currentDate)
                        }){
                            Image("icon_date_picker_left")
                        }
                        Text("\(selectYear)年\(selectMonth)月").font(.title2)
                        // 选择下个月日期
                        Button(action: {
                            currentDate =  currentDate.nextMonth()
                            selectYear = Date.getYearByDate(date: self.currentDate)
                            selectMonth = Date.getMonthByDate(date: self.currentDate)
                        }){
                            Image("icon_date_picker_right")
                        }
                    }.frame(height: 50)
                    CalendarView(statusCode: 0,selectMonth: $selectMonth,selectYear: $selectYear)
                }
            })
        }
    }
}


#Preview {
//    DateSelect()
}
